home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1998 July
/
EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso
/
earkit
/
news
/
thor
/
rexx
/
bbsread
/
bouncemsg.br
< prev
next >
Wrap
Text File
|
1998-05-24
|
4KB
|
182 lines
/*
** $VER: BounceMsg.br 1.0 (13.5.97)
** by Eirik Nicolai Synnes
**
*/
options results
options failat 31
parse arg arguments
template = 'SYSTEM/A,CONFERENCE/A,MSGNO/A/N,USERLIST/A,BCC/S'
/*
** INITIALIZATION
*/
EVE_ENTERMSG = 0 /* Enter message */
EVE_REPLYMSG = 1 /* Reply message */
EVE_FORWARDMSG = 9 /* Forward message (only TCP/SOUP) */
MDB_URGENT = 11 /* Message is urgent. */
MDB_RETURNRECEIPT = 26
MDB_ENCODE8BIT = 27
/*
** Check if BBSREAD's ARexx port is open, open it if it's not
*/
if ~(show('P', 'BBSREAD')) then do
address(command)
'Run >NIL: `GetEnv THOR/THORPath`bin/LoadBBSRead'
if exists('SYS:RexxC/WaitForPort') then 'SYS:RexxC/WaitForPort BBSREAD'
else 'WaitForPort BBSREAD'
if (rc = 5) then do; say 'Could not open BBSREAD''s ARexx port.'; exit(30); end
if (rc ~= 0) then do; say 'Could not find SYS:Rexxc/WaitForPort.'; exit(30); end
end
/*
** Parse command line
*/
if (arguments = '') | (arguments = '?') then do
say 'Template: 'template
say 'BounceMsg.br is an external script for SortMail.'
exit(20)
end
address(bbsread)
'READARGS 'template args' CMDLINE 'arguments
if (rc ~= 0) then do
say 'Template: 'template
say 'READARGS failed: 'BBSREAD.LASTERROR
exit(rc)
end
/*
** Get system and message data
*/
'GETBBSDATA "'args.system'" 'bbsdata
if (rc ~= 0) then do
say 'GETBBSDATA: 'BBSREAD.LASTERROR
exit(rc)
end
if (symbol('bbsdata.EMAILADDR') ~= 'VAR') then do
say 'No email address configured for system "' || bbsdata.NAME || '".'
exit(20)
end
'READBRMESSAGE "'args.system'" "'args.conference'" 'args.MSGNO' DATASTEM 'msgdata' HEADSTEM 'msghead
if (rc ~= 0) then do
say 'READBRMESSAGE, data & head stem: 'BBSREAD.LASTERROR
exit(rc)
end
/*
** See if the message is from the local user, exit if so
*/
if (msghead.FROMADDR = bbsdata.EMAILADDR) then exit(0)
/*
** Get addresses to mail message to
*/
'SEARCHBRUSER "'args.system'" STEM 'user' SEARCH "'args.USERLIST'" NAME'
if (rc ~= 0) then do
say 'SEARCHBRUSER: 'BBSREAD.LASTERROR
exit(rc)
end
if (result = 0) then do
say 'No user with the name "'args.USERLIST'".'
exit(20)
end
'READBRUSER BBSNAME "'args.system'" USERNR 'user.1.USERNR' TAGSSTEM 'usertags' DATASTEM 'userdata
if (rc ~= 0) then do
say 'READBRUSER: 'BBSREAD.LASTERROR
exit(rc)
end
if (symbol('usertags.ADDRESS') ~= 'VAR') | (strip(usertags.ADDRESS, 'B') = '') then do
say 'User "'args.USERLIST'" does not have any addresses defined.'
exit(20)
end
/*
** Get global configuration
*/
'GETGLOBALDATA 'globdata
if (rc ~= 0) then do
say 'GETGLOBALDATA: 'BBSREAD.LASTERROR
exit(rc)
end
if (right(globdata.TMPDIR, 1) ~= '/') & (right(globdata.TMPDIR, 1) ~= ':') then globdata.TMPDIR = globdata.TMPDIR || '/'
/*
** Create event data
*/
eventdata.TOADDR = bbsdata.EMAILADDR
eventdata.TONAME = usertags.NAME
eventdata.SUBJECT = msghead.SUBJECT
eventdata.CONFERENCE = 'EMail'
eventdata.REFCONFERENCE = args.CONFERENCE
eventdata.REFNR = args.MSGNO
if (symbol('msghead.MSGID') = 'VAR') then eventdata.REFID = msghead.MSGID
if (bittst(msgdata.flags, MDB_URGENT)) then eventdata.URGENT = 1; else eventdata.URGENT = 0
if (bittst(msgdata.flags, MDB_RETURNRECEIPT)) then eventdata.RETURNRECEIPT = 1; else eventdata.RETURNRECEIPT = 0
if (bittst(msgdata.flags, MDB_ENCODE8BIT)) then eventdata.ENCODE8BIT = 1; else eventdata.ENCODE8BIT = 0
/*
** Create message file with headers
*/
'UNIQUEMSGFILE BBSNAME "'args.system'" STEM 'msgfile
if (rc ~= 0) then do
say 'UNIQUEMSGFILE: 'BBSREAD.LASTERROR
exit(rc)
end
eventdata.MSGFILE = msgfile.FILEPART
if open(msgf, msgfile.NAME, 'A') then do
call writeln(msgf, 'From: ' || msghead.FROMNAME || ' <' || msghead.FROMADDR || '>')
call writeln(msgf, 'Reply-To: ' || bbsdata.EMAILADDR)
if (args.BCC) then call writeln(msgf, 'Bcc: ' || usertags.ADDRESS)
else call writeln(msgf, 'Cc: ' || usertags.ADDRESS)
call close(msgf)
end
else do
say 'Could not open message file.'
exit(20)
end
/*
** Write the new event
*/
'WRITEBREVENT BBSNAME "'args.system'" EVENT 'EVE_FORWARDMSG' STEM 'eventdata
if (rc ~= 0) then do
say 'WRITEBREVENT: 'BBSREAD.LASTERROR
exit(rc)
end
exit(0)